// 页面中类型定义

export interface ResData<T> {
  code: number
  message: string
  data: T
}

export interface Pagination {
  current: number
  pages: number
  size: number
  total: number
}

/**
 * 通用表单数据接口，用于与后端API交互
 */
export interface FormData {
  id?: string
  name: string
  description?: string | null
  code?: string
  sort?: number
  createdAt?: string
  updatedAt?: string
}

// pagelist 接口 - 使用RoleItem类型以避免与Record接口冲突
export interface PageList {
  records: RoleItem[]
  searchCount: boolean
  size: number
  total: number
  current: number
  pages?: number
}

export type ResPageList = ResData<PageList>

/** 角色项 */
export interface RoleItem {
  id: string
  name: string
  code: string
  sort: number
  description?: string | null
  createdAt?: string
  updatedAt?: string
}

/** 权限树节点 */
export interface PermissionNode {
  id: string
  createdAt?: string
  updatedAt?: string
  pid: string | null
  name: string
  code?: string | null
  toCode?: string | null
  type: number
  status?: string | null
  level: number
  children: PermissionNode[]
  select: boolean
}

/** 分配权限接口返回的数据体 */
export interface AssignPermissionData {
  allPermission: PermissionNode[]
  assignPermission: string[]
}

export type ResAssignPermissionData = ResData<AssignPermissionData>

// 定义搜索参数类型，避免与 Record 接口命名冲突
export type SearchParams = { [key: string]: unknown }
